package com.zzx.util;

import com.zzx.exception.ExceptionState;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseResult<T> {
    private T data;
    public Meta meta;

    /*只返回是否成功*/
    public ResponseResult(String msg,ExceptionState state){
        Meta meta = new Meta(msg, state.getStatus());
        this.meta = meta;
    }
    public ResponseResult(ExceptionState state){
        Meta meta = new Meta(state.getDescribe(), state.getStatus());
        this.meta = meta;
        this.data = null;
    }

    public ResponseResult  UNKNOWN(String data){
        Meta meta = new Meta(data,ExceptionState.UNKNOWN.getStatus());
        this.meta = meta;
        this.data = null;
        return this;
    }

    public ResponseResult(String msg,ExceptionState state,T data){
        Meta meta = new Meta(msg, state.getStatus());
        this.meta = meta;
        this.data = data;
    }
    /* 没有数据成功*/
    public static ResponseResult Ok(String msg,ExceptionState state){
        return new ResponseResult(msg,state);
    }



}
